//206. 反转链表
//思路：将每个节点的next域改为上一个节点的地址，最后返回最后一个节点的地址
//循环体里面的语句顺序不能改变
#include <stdio.h>
struct ListNode {
    int val;
    struct ListNode* next;
};
struct ListNode* reverseList(struct ListNode* head) {
    struct ListNode* prev = NULL, * cur = head, * next = NULL;
    while (cur)
    {
        next = cur->next;
        cur->next = prev;
        prev = cur;
        cur = next;
    }
    return prev;
}